#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <armadillo>
#include <iomanip>
#include <vector>

using namespace std;
using namespace arma;

#include "optflow_feat_def.hpp"
#include "optflow_feat_impl.hpp"



uword ro = 120;
uword co = 160;
//Optical Flow features
//Knn classifier: N=3

//NICTA
const std::string path = "/home/johanna/codes/multi-actions/kth_testing/"; 
const std::string path_multi = "/home/johanna/codes/multi-actions/kth_multi/"; 


//Home
//const std::string path = "/home/johanna/codes-svn/multi-action/kth_testing/";
//const std::string path_multi = "/home/johanna/codes-svn/multi-action/kth_multi/"; 

//UQ-server
//const std::string path = "/home/users/uqjcarva/Johanna/codes-linux/multi-actions/kth_testing/"; 



//wanda
//const std::string path = "/data2/Users/johanna/codes-wanda/kth_testing/";



////When I need to save
const std::string  feat_path ="./flow_features/"; //Create this folder


///OJO!!!!!!!!!!!!!!
const std::string  actionNames = "actionNames.txt";



int
main(int argc, char** argv)
{
  
  vec Ncents;
  Ncents << 16 << 32 << endr;
  
  int L_segm =25;
  
 
  
  ///Clustering
  /*
   for (uword n=0; n<Ncents.n_elem; ++n)
  {
  int N_cent = Ncents(n);
  opt_feat kth_optflow(path, actionNames, feat_path, co, ro, N_cent, L_segm);
  kth_optflow.clustering_per_action(); 
  
  }
  
  */

  
  ///Linear Kernel
  int N_cent = 16;
  opt_feat kth_optflow(path, actionNames, feat_path, co, ro, N_cent, L_segm); 
  
  
   float Cvalue = 0.01; 
  
  std::string model_name = "multi_svm_model_linear";
  kth_optflow.training_svm(model_name, "LINEAR", 0, Cvalue);   // last parameter is gamma. Don't need for Linear Kernel
  kth_optflow.testing_training (model_name);
  kth_optflow.testing_svm(path_multi, model_name);
  //getchar();


  
  
  //sigma_set <<0.01 << 0.03 << 0.1 << 0.3 << 1 <<  3 << 10 << 30;
  //
  
  
/*
  rowvec sigma_set; 
  sigma_set <<0.01 <<  0.1 << 0.3 << 1 << 3 << 10 << 30;
  //sigma_set << 30 << 40 << 50 << 100 ;
  for (uword gm=0; gm<sigma_set.n_elem; ++gm)
  {
    
    float gamma = 1/( 2*pow( sigma_set(gm),2 ) );
  //cout << "Training with 15 features: " << endl;
  //
  
    std::stringstream model_name;
    model_name << "multi_svm_modelRBF_sigma_" << sigma_set (gm);
    cout << model_name.str() << endl;
    kth_optflow.training_svm(model_name.str(), "RBF", gamma);  
    kth_optflow.testing_training (model_name.str());
    kth_optflow.testing_svm( path_multi, model_name.str() );
    //getchar();
  
  }
  */

}









/*
 c **** *ma*ke_minimum_required(VERSION 2.8)
 project( grassmann_clustering)
 find_package( OpenCV REQUIRED)
 find_package( Armadillo REQUIRED)
 add_executable( run_3actions.exe Three_actions_UCF11.cpp)
 target_link_libraries( run_3actions.exe ${OpenCV_LIBS} -O1 -larmadillo)
 */
